package com.team7.home.controller;

import com.team7.common.vo.CommonResult;
import com.team7.common.vo.TouVo;
import com.team7.home.service.HeadNavService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: team7-object-master
 * @description:
 * @author: 王金涛
 * @create: 2021-10-20 19:29
 **/

@RestController
@RequestMapping("/home/head")
@Api
public class HeadNavController {
    @Autowired
    private HeadNavService headNavService;

    @PostMapping("getAllHeadNav/{page}/{limit}")
    public CommonResult getAllHeadNav(@PathVariable("page") Integer page,
                                      @PathVariable("limit") Integer limit,
                                      @RequestBody TouVo touVo){
        return headNavService.getAllHeadNav(page, limit, touVo);
    }

    /**
     * 添加头部导航栏
     * @param touVo
     * @return
     */
    @PostMapping("addHeadNav")
    public CommonResult addHeadNav (@RequestBody TouVo touVo){
        return headNavService.addHeadNav(touVo);
    }

    @PostMapping("changeStatus/{headId}/{isDiable}")
    public CommonResult changeStatus(@PathVariable("headId") Integer headId,
                                     @PathVariable("isDiable") String isDiable){
        return headNavService.changeStatus(headId,isDiable);
    }

    @PostMapping("deleteHeadNav")
    public CommonResult deleteHeadNav(@RequestBody TouVo touVo){
        return headNavService.deleteHeadNav(touVo.getHeadId());
    }
}
